package com.andy.blog.admin.service.impl;

import com.andy.blog.admin.dto.SysOperLogDTO;
import com.andy.blog.admin.service.SysOperLogBusService;
import com.andy.blog.common.page.PageUtilsDTO;
import com.andy.blog.common.utils.TransformUtils;
import com.andy.blog.dal.domain.SysOperLogDO;
import com.andy.blog.dal.service.SysOperLogDalService;
import com.andy.blog.dal.vo.SysOperLogVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by andy on 2023-04-30 15:12
 */
@Service
public class SysOperLogBusServiceImpl implements SysOperLogBusService {

    @Resource
    private SysOperLogDalService sysOperLogDalService;

    @Override
    public PageUtilsDTO<SysOperLogDTO> selectListByPage(SysOperLogVO sysOperLogVO) {
        IPage<SysOperLogDO> page = sysOperLogDalService.selectListByPage(sysOperLogVO);
        return PageUtilsDTO.build(page.getTotal(), TransformUtils.transformList(page.getRecords(), SysOperLogDTO.class));
    }

    @Override
    public List<SysOperLogDTO> selectListByCondition(SysOperLogVO sysOperLogVO) {
        List<SysOperLogDO> sysOperLogDOS = sysOperLogDalService.selectListByCondition(sysOperLogVO);
        return TransformUtils.transformList(sysOperLogDOS, SysOperLogDTO.class);
    }

    @Override
    public void deleteByIds(List<Long> ids) {
        sysOperLogDalService.deleteByIds(ids);
    }

    @Override
    public void cleanOperLog() {
        sysOperLogDalService.cleanOperLog();
    }
}
